package com.ecmp.basic.test;

import com.ecmp.context.ContextUtil;
import com.ecmp.config.ServiceConfig;
import com.ecmp.vo.SessionUser;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

//让测试运行于spring测试环境
@RunWith(SpringJUnit4ClassRunner.class)
//指定加载的文件
@ContextConfiguration(classes = ServiceConfig.class)
public class UnitTestBase {
    @Autowired
    //注入指定名称的bean
    @Qualifier("sessionRedisTemplate")
    protected RedisTemplate redisTemplate;

    @Before
    public void initTest() throws Exception {
        //通过上下文取得模拟用户
        ContextUtil.mockUser();
        System.out.println(ContextUtil.getTenantCode()+"-"+ContextUtil.getUserAccount());
    }
}
